
package main.java.org.gravity;

/*
 * Author: Fami
 * version: 0.1
 * File: OSProcChecker
 * Repo: https://code.google.com/p/osprocchecker/
 * License: MIT License
 * Desc: Grab the designated windows process PID name to check the existence of those process
 */

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;

import org.gravity.Function;		//opensource lib: "https://code.google.com/p/gravity-jio/"	

public class OSProcChecker {
	
	public static void writeOut(String filePath , String fileName , String inputWrite ) throws IOException{
        try {
        	String timestamp = Function.timestamp();
        	File file = new File(filePath + "/" + fileName);
        	String nextLine = System.getProperty("line.separator"); //avoid platform dependencies, windows \r\n
        	
        	PrintStream printFile = new PrintStream(new FileOutputStream(file, true));
        	printFile.append("");
        	printFile.append(nextLine+timestamp+": "+inputWrite+"\n");
        	System.out.println("INFO: Write input to file SUCCEED!. File location: "+file);
        	printFile.close(); //Close the file to end the Streaming 
        		
                
        } catch (FileNotFoundException writeError) {
                System.out.println("Write Out FAIL!, due to:\n");
                writeError.printStackTrace();
        }
	}
	
	
	public static void main (String args[]){
		
		try{
			osProcGui.osProcWindow();
		
		} catch (Exception guiFail) {
            System.out.println("OSProcChecker GUI FAIL!! to invoke, due to:\n");
            guiFail.printStackTrace();
		}
	}
}

